
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import { eslint } from 'rollup-plugin-eslint'
import filesize from 'rollup-plugin-filesize'
import pkg from './package.json'
const dev = process.env.NODE_ENV === 'development'
export default [
  // browser-friendly UMD build
  {
    input: 'src/index.js',
    output: [
      {
        name: pkg.name,
        file: pkg.browser,
        format: 'iife'
      },
      {
        name: pkg.name,
        file: pkg.common,
        format: 'umd'
      },
      { file: pkg.main, format: 'cjs' },
      { file: pkg.module, format: 'es' }
    ],
    watch: {
      exclude: 'node_modules/**'
    },
    plugins: [
      dev && eslint({
        include: ['src/**'],
        throwOnError: true,
        exclude: ['node_modules/**', 'test/**']
      }),
      resolve(),
      commonjs(),
      babel({
        exclude: 'node_modules/**'
      }),
      !dev && terser(),
      !dev && filesize()
    ]
  }
]
